package com.itheima.dubbo.api;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.itheima.dubbo.mapper.UserMapper;
import com.tanhua.domain.db.User;
import com.tanhua.dubbo.api.UserApi;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;

@Service
public class UserApiImpl implements UserApi {

    @Autowired
    private UserMapper userMapper;

    @Override
    public long save(User user) {
        userMapper.insert(user);
        return  user.getId();

    }

    @Override
    public void update(User user) {
        userMapper.updateById(user);
    }

    @Override
    public User findByMobile(String mobile) {
        QueryWrapper<User> wrapper = new QueryWrapper<>();
        wrapper.eq("mobile",mobile);
        return userMapper.selectOne(wrapper);
    }


}
